package com.linux4fun.singleton;

/**
 * 懒加载模式
 * https://kylepeng93.github.io
 *
 * @author pengkai
 * @date 2021-03-21 上午11:45
 */
public class LazyInitialization {

    private static LazyInitialization instance;

    private LazyInitialization() {};

    public static LazyInitialization getInstance() {
        // 如果未被实例化，则初始化，如此则为懒加载，但存在线程安全的问题
        if (instance == null) {
            instance = new LazyInitialization();
        }
        return instance;
    }
}
